<script type="text/javascript" src="jquery.js"> </script>		
<script type="text/javascript" src="prototype.js"> </script>
<script type="text/javascript" src="JForm.js"></script>
	<script type="text/javascript">
	dojo.require("dojo.parser");  
	dojo.require("dijit.layout.LinkPane");
     // Load Dojo's code relating to the Button widget
	dojo.require("dijit.Dialog");
	dojo.require("dijit.form.TextBox");
	dojo.require("dijit.form.TimeTextBox");
	dojo.require("dijit.form.Button");
	dojo.require("dijit.form.DateTextBox");
</script>  
<!-- --------------------- -->

<%
	//session id 
	String userid = (String) session.getValue("user");
	List contractList = ContractService.$.getAllContracts();
 %>

<fieldset>
	<legend>合同列表</legend>
		<table align="left"  border="1px">
			<thead>
				<tr>
					<th>公司名称</th>
					<th>机构代码</th>
					<th>法人代表</th>
					<th>联系人</th>
					<th>联系电话</th>
					<th>合同金额</th>
					<th>合同起始日期</th>
					<th>合同结束日期</th>
					<th>企业</th>
				</tr>
			</thead>
			<tbody>
			<%
				for(int i = 0 ; i < contractList.size(); i++) {
					Contract contract = (Contract) contractList.get(i);	
			%>
				<tr>
					<td><%= contract.getEnterpriseName()%></td>
					<td><%= contract.getOrgdeptcode()%></td>
					<td><%= contract.getLegalrepresentative()%></td>
					<td><%= contract.getContact()%></td>
					<td><%= contract.getContactNumber()%></td>
					<td><%= contract.getContractAmount()%></td>
					<td><%= contract.getStarteddate()%></td>
					<td><%= contract.getDuedate()%></td>
					<%
						Enterprise enterprise = contract.getEnterprise(); 
						boolean hasChild = null == enterprise ? false : true; 
						String[] pars = new String[1];
						if(hasChild) {
							pars[0] = "'" + "enterpriseid=" + enterprise.getEsmsId() + "'"; 
					%> 
						<td><%= JspWidget.$.actionButton("企业1","la_enterprise_create.jsp", pars,"right") %></td>
					<%} else{
							pars[0] = "'" + "contractid=" + contract.getContractId() + "'"; 
					%>
					<td><%= JspWidget.$.actionLink("创建企业","la_enterprise_create.jsp", pars) %>
					<%= JspWidget.$.actionButton("企业1","la_enterprise_create.jsp", pars,"right") %>
					<%= JspWidget.$.actionButton("企业2","enterprise_main_page.jsp", pars,"right") %>
					</td>
					<%}%>
					<td><a> 创建企业 </a></td>
				</tr>	
					
				<%
					}
				%>
				<tr>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<%	
						String contractid = "11111111111111";
						String enterpriseid = "2222222222";
						Contract c = null;
						boolean hasChild = false; // getEnterprise  
						String[] pars = new String[1];
						if(hasChild) {
							pars[0] = "'" + "enterpriseid=" + enterpriseid+ "'"; 
					%> 
						<td><%= JspWidget.$.actionButton("企业1","la_enterprise_create.jsp", pars,"right") %></td>
					<%} else{
							pars[0] = "'" + "contractid=" + contractid+ "'"; 
					%>
					<td><%= JspWidget.$.actionLink("创建企业","la_enterprise_create.jsp", pars) %>
					<%= JspWidget.$.actionButton("企业1","la_enterprise_create.jsp", pars,"right") %></td>
					<%}%>
				</tr>	
				<tr>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td><a href="javascript:;" title="转到企业1"> 企业1 </a></td>
				</tr>	
			</tbody>
		</table>
</fieldset>

<%@ page import="java.util.*" %>
<%@ page import="com.esms.bean.Contract" %>
<%@ page import="com.esms.struts.service.*" %>
<%@ page import="com.esms.bean.*" %>
<%@ page language="java" contentType="text/html; charset=utf-8" %>